home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Feb 18 1996
- // Author: cdg
- //
- // Description:
- // Delete a panel. If it is visible replace it with another panel.
- // If it is torn off then also delete its window.
- //
- // Input Arguments:
- // $whichPanel: The name of the panel to be deleted.
- //
- // Return Value:
- // None.
- //
- // Note:
- // None.
- //
-
-
- global proc deletePanel (string $whichPanel) {
- //
- // Description:
- // Delete a panel. If it is visible replace it with another panel.
- // If it is torn off then also delete its window.
- //
- //
- global string $gMainPane;
- global string $gPanelEditorWnd;
-
- string $winName;
- string $panelControl;
- string $p1,$p2,$p3,$p4;
- string $msg;
- int $pane = 0;
- int $nVisPanes;
- string $panels[];
- string $controls[];
-
- if (`panel -exists $whichPanel`) {
- //
- // First check to confirm that this wasn't a mistake.
- //
- $msg = ("Are you sure you want to permanently delete '" + $whichPanel + "'?");
- if ("OK" == `confirmDialog -title "Confirm" -message $msg
- -button "OK" -button "Cancel" -defaultButton "OK"
- -cancelButton "Cancel" -dismissString "Cancel"
- -parent $gPanelEditorWnd`)
- {
- //
- // Okay to delete.
- //
- if (`panel -q -to $whichPanel`) {
- //
- // panel is torn off so get rid of its window first.
- //
- $winName = match("^[^|]*",`panel -q -control $whichPanel`);
- deleteUI -window $winName;
-
- } else {
- $panelControl = `panel -q -control $whichPanel`;
- if ("" != $panelControl) {
- $panelControl = match("[^|]*$",$panelControl);
- //
- // Panel is parented. Assume that it is in the main pane
- // since it is not torn off.
- //
- $p1 = `paneLayout -q -p1 $gMainPane`;
- $p2 = `paneLayout -q -p2 $gMainPane`;
- $p3 = `paneLayout -q -p3 $gMainPane`;
- $p4 = `paneLayout -q -p4 $gMainPane`;
- $nVisPanes = `paneLayout -q -nvp $gMainPane`;
-
- if ($panelControl == $p1) {
- $pane = 1;
- } else if ($panelControl == $p2 && $nVisPanes > 1) {
- $pane = 2;
- } else if ($panelControl == $p3 && $nVisPanes > 2) {
- $pane = 3;
- } else if ($panelControl == $p4 && $nVisPanes > 3) {
- $pane = 4;
- }
- if ($pane > 0) {
- //
- // Panel is in one of the visible main panes, so
- // it should be replaced with something else.
- //
-
- //
- // First try to replace with something that is already
- // parented to the same paneLayout.
- //
- string $replacementPanel = "";
- string $cmdStr;
-
- $controls = `paneLayout -q -ca $gMainPane`;
- for ($control in $controls) {
- if ($control != $panelControl &&
- $control != $p1 &&
- ($nVisPanes < 2 || $control != $p2) &&
- ($nVisPanes < 3 || $control != $p3) &&
- ($nVisPanes < 4 || $control != $p4)
- )
- {
- $replacementPanel = `getPanel -containing $control`;
- if ("" != $replacementPanel) {
- break;
- }
- }
- }
-
- if ("" == $replacementPanel) {
- //
- // Try to parent an unparented panel.
- //
- $panels = `getPanel -allPanels`;
- for ($panel in $panels) {
- if ("" == `panel -q -control $panel`) {
- $replacementPanel = $panel;
- break;
- }
- }
- }
-
- if ("" == $replacementPanel) {
- //
- // Make an new model panel to fill the spot.
- //
- $replacementPanel = `modelPanel -unParent`;
- modelPanel -e
- -label `interToUI $replacementPanel`
- $replacementPanel;
-
- }
-
- if ("" == `panel -q -control $replacementPanel`) {
- //
- // parent it to the main pane layout.
- //
- $cmdStr = `getPanel -typeOf $replacementPanel`;
- $cmdStr += (" -e -parent $gMainPane " + $replacementPanel);
- eval $cmdStr;
- }
-
- //
- // Move it to the correct pane.
- //
- paneLayout -e
- -sp `panel -q -control $replacementPanel` $pane
- $gMainPane;
- }
- }
- }
-
- // Finally, delete the panel.
- //
- deleteUI -panel $whichPanel;
- }
- } else {
- warning("Unable to delete '"+ $whichPanel +"'. Panel not Found.");
- }
- }
-